from PyQt5.QtWidgets import QApplication,QWidget,QLabel,QLineEdit,QTextEdit,QVBoxLayout
from PyQt5.QtWidgets import QPushButton,QHBoxLayout,QFormLayout
from PyQt5.QtGui import QIcon,QPixmap
import sys
def btn_clicked():
    print("提交用户信息")
def init_Widget(window:QWidget):
    # #创建水平排列的布局
    # layout = QHBoxLayout()
    # btn=QPushButton("按钮1")
    # btn1=QPushButton("按钮1")
    # btn2=QPushButton("按钮2")
    # btn3=QPushButton("按钮3") 
    # #添加按钮到布局
    # layout.addWidget(btn)
    # layout.addWidget(btn1)
    # layout.addWidget(btn2)
    # layout.addWidget(btn3)
    #创建竖直布局
    # layout =QVBoxLayout()
    # btn=QPushButton("按钮1")
    # btn1=QPushButton("按钮1")
    # btn2=QPushButton("按钮2")
    # btn3=QPushButton("按钮3") 
    # #添加按钮到布局
    # layout.addWidget(btn)
    # layout.addWidget(btn1)
    # layout.addWidget(btn2)
    # layout.addWidget(btn3)
    #表单布局
    layout = QFormLayout()
    edit_user=QLineEdit()
    edit_pwd=QLineEdit()
    edit_user.setPlaceholderText("请输入用户名")
    edit_pwd.setPlaceholderText("请输入密码")   
    #设置密码输入框
    edit_pwd.setEchoMode(QLineEdit.Password)
    #设置提交按钮
    btn=QPushButton("提交")
    btn.clicked.connect(btn_clicked)
    #添加到布局
    layout.addRow("用户名:", edit_user)
    layout.addRow("密码:", edit_pwd)
    layout.addRow(btn)
    window.setLayout(layout)

if __name__ == "__main__":
    # 创建QApplication对象
    app=QApplication(sys.argv)
    #创建窗口
    window=QWidget()
    #命名窗口
    window.setWindowTitle("上位机")
    #指定图标
    window.setWindowIcon(QIcon("gege.png"))
    #设置窗口大小
    window.resize(1000, 800)
    #——————————————————————————————————————组件初始化
    init_Widget(window)

    #_____________________________________
    #显示窗口
    window.show()
    #鼠标悬浮文字
    window.setToolTip("你好")
    #结束
    sys.exit(app.exec_())
    